
package com.market.web.action;

import java.util.List;

import com.market.bean.Product;
import com.market.constant.Constant;
import com.market.web.form.ProductForm;
import com.market.web.tag.Pages;
import com.market.web.utils.ListUtils;

public class DiscountAction extends ProductAction
{
    public String execute() throws Exception
    {
        int curP = (int)getLong("page");
        if (curP == 0)
        {
            curP++;
        }
        int count = getProductService().getCountByDiscount();
        List list = getProductService().getDiscountList((curP - 1) * Constant.perPage, Constant.perPage);
        StringBuffer path = new StringBuffer();
        path.append(getRequest().getServletPath()).append(".do?");
        System.out.println("xxxxxxxxx:path is"+path);
        Pages pages = new Pages();
        pages.setCurPage(curP);
        pages.setRowCount(count);
        pages.setPerPage(Constant.perPage);
        pages.setPath(path.toString());
        getRequest().setAttribute(Constant.PAGES, pages);
        getRequest().setAttribute("productList", ListUtils.convert(list, Product.class, ProductForm.class));
        return SUCCESS;
        //return mapping.findForward("discount");
    }

}
